<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8">
		<title>Computer room</title>
		<link rel="stylesheet" type="text/css" href="plugins/bootstrap-3.3.7-dist/css/bootstrap.min.css"/>
		<link rel="stylesheet" type="text/css" href="css/global.css" />
		<link rel="stylesheet" type="text/css" href="css/computer_room.css"/>
		<script type="text/javascript">
			window.$ = window.jQuery = require('./jquery-3.3.1.min');
		</script>
		<script src="plugins/bootstrap-3.3.7-dist/js/bootstrap.min.js" type="text/javascript" charset="utf-8"></script>
		<script src="plugins/layer/layer.js" type="text/javascript" charset="utf-8"></script>
		<script src="plots.js" type="text/javascript" charset="utf-8"></script>
		<script src="libs.js" type="text/javascript" charset="utf-8"></script>
	</head>
	<body>
		<audio id="voice" src="">
			当前浏览器不支持audio
		</audio>
		<div id="show_day" style="text-align: center;font-size: 30px;">
			第
			<label>0</label>
			天
		</div>
		<div>
			<button type="button" class="btn btn-default btn-icon" onmouseover="e2c(voice, this, this.innerHTML);" onmouseleave="c2e(this, this.innerHTML);" onclick="show_map();">Map</button>
			<button type="button" class="btn btn-default btn-icon" onmouseover="e2c(voice, this, this.innerHTML);" onmouseleave="c2e(this, this.innerHTML);" onclick="turn_on();" style="width: 130px;">Turn on</button>
		</div>
		<div class="hidden" id="map">
			<a class="btn btn-link map_item" href="livingroom.html" onmouseover="e2c(voice, this, this.innerHTML);" onmouseleave="c2e(this, this.innerHTML);">livingroom</a>
		</div>
		
		<script type="text/javascript">
			var fs = require('fs');
			var voice = document.getElementById('voice');
			
			if (!fs.existsSync('current.json')) {
				layer.alert('Can\'t find current.json', {icon: 2});
			} else {
				var current_json_str = fs.readFileSync('current.json');
				var source_json_name = JSON.parse(current_json_str).target;
				var json_str = fs.readFileSync('archives/' + source_json_name);
				var json = JSON.parse(json_str.toString());
				$('#show_day label').html(json.day);
				json.local = 'computer_room';
				fs.writeFileSync('archives/' + source_json_name, JSON.stringify(json));
			}
			
			function turn_on() {
				location.href = 'screen.html?type=computer';
			}
		</script>
	</body>
</html>
